﻿using System;
using System.Collections.Generic;
using System.Linq;
using Kaiser.Extensions;
using Kaiser.Repositories;

namespace Kaiser.Domains
{
    public abstract class AggregateRoot : IDomain, IDisposable
    {
        public virtual long Id { get; set; }

        public void Dispose()
        {
             
        }
    }

    public class EntityBase<T> : AggregateRoot where T : AggregateRoot, new()
    {
        public static IList<T> List=new List<T>(); 
        public static void Add(T item)
        {
            List.Add(item);
        }

        public static void AddList(IList<T> items)
        {
            items.ForEach(x => List.Add(x));
        }

        public static IList<T> FindAll()
        {
            return List;
        }

        public static void Edit(T model)
        {
            //list.Contains(model)
        }

        public static void Remove(T model)
        {
            List.Remove(model);
        }
        public static void Remove(long id)
        {
           
        }
        public static void DelList(IList<T> model)
        {
        }
        public static T Get(object primaryId)
        {
            return List.FirstOrDefault(x => primaryId != null && x.Id == (long)primaryId);
        }

        public static T Get(int index)
        {
            return List[index];
        }

        public static T Create() {

            return new T();
        }


    }
}
